/*********************************************************************************
 * 
 * Author: wujunjie
 * Create Date: 2014-05-10
 * Description:
 *          
 * Revision History:
 *      Date          Author               Description
 * 
*********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataFrameworkAccess;
using Xinkui.Entity.AutoGenerator;
using Xinkui.Common;
namespace Xinkui.DataAccess.AutoGenerator {
    public partial class CommonCategoryDataAccess
    {
        public List<CommonCategory_Entity> CommonCategory_ListByPaging(int pageSize, int pageIndex,out int total)
        {
			total= 0;
            try
            {
				int tempRecord = 0;
                DataCommand cmd = DataCommandManager.GetDataCommand("CommonCategory_ListByPaging");
                cmd.SetParameterValue("@PageSize", pageSize);
                cmd.SetParameterValue("@PageIndex", pageIndex);
				cmd.SetParameterValue("@RecordCount", tempRecord);
                List<CommonCategory_Entity> pageList = cmd.ExecuteEntityList<CommonCategory_Entity>();
                total = Convert.ToInt32(cmd.GetParameterValue("@RecordCount"));
				return pageList;
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }

            return new List<CommonCategory_Entity>(0);

        }

        public CommonCategory_Entity CommonCategory_View(System.Int32 CategoryID)
        {
            CommonCategory_Entity c = default(CommonCategory_Entity);
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("CommonCategory_View");
                cmd.SetParameterValue("@CategoryID", CategoryID);
                c = cmd.ExecuteEntity<CommonCategory_Entity>();
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }
            return c;
        }

        public CommonCategory_Entity CommonCategory_Add(CommonCategory_Entity entity)
        {
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("CommonCategory_Add");
                cmd.SetParameterValue("@CategoryID", entity.CategoryID);
                cmd.SetParameterValue("@Title", entity.Title);
                cmd.SetParameterValue("@OrderBy", entity.OrderBy);
                cmd.SetParameterValue("@KeyWord", entity.KeyWord);
                cmd.SetParameterValue("@ParentID", entity.ParentID);
                cmd.SetParameterValue("@IsFloor", entity.IsFloor);
                cmd.SetParameterValue("@Depth", entity.Depth);
                cmd.SetParameterValue("@DirPath", entity.DirPath);
                cmd.SetParameterValue("@ImageFile", entity.ImageFile);
                cmd.SetParameterValue("@Description", entity.Description);
                cmd.SetParameterValue("@Status", entity.Status);
                cmd.SetParameterValue("@ClassID", entity.ClassID);
                cmd.SetParameterValue("@RelationCategories", entity.RelationCategories);
                cmd.SetParameterValue("@RelationKeywords", entity.RelationKeywords);
                cmd.SetParameterValue("@CategoryAPP", entity.CategoryAPP);
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }

            return entity;
        }

        public bool CommonCategory_Update(CommonCategory_Entity entity)
        {
            bool succ = false;
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("CommonCategory_Update");
                cmd.SetParameterValue("@CategoryID", entity.CategoryID);
                cmd.SetParameterValue("@Title", entity.Title);
                cmd.SetParameterValue("@OrderBy", entity.OrderBy);
                cmd.SetParameterValue("@KeyWord", entity.KeyWord);
                cmd.SetParameterValue("@ParentID", entity.ParentID);
                cmd.SetParameterValue("@IsFloor", entity.IsFloor);
                cmd.SetParameterValue("@Depth", entity.Depth);
                cmd.SetParameterValue("@DirPath", entity.DirPath);
                cmd.SetParameterValue("@ImageFile", entity.ImageFile);
                cmd.SetParameterValue("@Description", entity.Description);
                cmd.SetParameterValue("@Status", entity.Status);
                cmd.SetParameterValue("@ClassID", entity.ClassID);
                cmd.SetParameterValue("@RelationCategories", entity.RelationCategories);
                cmd.SetParameterValue("@RelationKeywords", entity.RelationKeywords);
                cmd.SetParameterValue("@CategoryAPP", entity.CategoryAPP);
                cmd.ExecuteNonQuery();
                succ = true;
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }
            return succ;
        }

        public bool CommonCategory_Delete(System.Int32 CategoryID)
        {
            bool succ = false;
            try
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("CommonCategory_Delete");
                cmd.SetParameterValue("@CategoryID", CategoryID);
                cmd.ExecuteNonQuery();
                succ = true;
            }
            catch (Exception ex)
            {
                ExceptionHelper.ProcessException(ex);
            }
            return succ;
        }
		
	}
}
